﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Helper">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Helper;component/Converters/Converters.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    <Style x:Key="{x:Type GroupBox}"
           TargetType="{x:Type GroupBox}">
        <Setter Property="Margin"
                Value="5" />
        <Setter Property="Padding"
                Value="5" />
        <Setter Property="Background"
                Value="{DynamicResource Accent}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource Accent}" />

        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type GroupBox}}, 
                        Path=Header, Mode=OneWay, Converter={StaticResource ToUpperConverter}}" Foreground="White"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GroupBox}">
                    <Grid x:Name="GroupBoxRoot">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <Border Grid.Row="0"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="1">
                            <ContentPresenter Margin="{TemplateBinding Padding}"
                                              ContentSource="Header"
                                              RecognizesAccessKey="True" />
                        </Border>
                        <Border Grid.Row="1"
                                Background="Transparent"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="1,0,1,1">
                            <ContentPresenter Margin="{TemplateBinding Padding}"
                                              Content="{TemplateBinding Content}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              Cursor="{TemplateBinding Cursor}" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
